<?php

namespace Tbf\Bundle\YntAuthBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Tests\Definition\Builder\SomeNodeDefinition;

/**
 * This is the class that validates and merges configuration from your app/config files
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritDoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('tbf_ynt_auth');

        // Here you should define the parameters that are allowed to
        // configure your bundle. See the documentation linked above for
        // more information on that topic.
        $rootNode
            ->children()
                ->append($this->getOneConfig('denglu'))
                ->append($this->getOneConfig('douban'))
                ;

        return $treeBuilder;
    }

    /**
     * @return NodeBuilder
     */
    public function getOneConfig($name){
        $nb = new ArrayNodeDefinition($name);
        $nb->children()
                ->scalarNode('app_key')->defaultNull()->example('2088xxx3234')->end()
                ->scalarNode('app_secret')->defaultNull()->example('2341234')->end()
            ->end()
        ;
        return $nb;
    }
}
